<?php
Class User extends CI_Model
{
	function login($username, $password){
		$this->db->select('user_id, username, password');
		$this->db->from('users');
		$this->db->where('username', $username);
		$this->db->where('password', MD5($password));
		$this->db->limit(1);
		$query = $this->db->get();
	
		if($query->num_rows() == 1){
		 return $query->result();
		}
		else{
		 return false;
		}
	}
	
	public function add_user(){
		$data=array('username'=>$this->input->post('username'),
					'password'=>md5($this->input->post('password'))
		);
		$this->db->insert('users',$data);
	}

	public function view_users(){
	    $query = $this->db->get('users');
	    return $query->result();
	}
}
?>